package com.itheima.service.impl;

import com.itheima.mapper.OrderMapper;
import com.itheima.pojo.Order;
import com.itheima.pojo.Orderdetail;
import com.itheima.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OrderServiceImpl implements OrderService {
    @Autowired
    private OrderMapper orderMapper;

    /**
     * 根据订单号查询订单信息和下单人信息
     * @param orderNumber
     * @return
     */
    @Override
    public Order getOrderByNumber(String orderNumber) {
        Order order = orderMapper.findOrderByNumber(orderNumber);
        return order;
    }

    /**
     * 根据订单号查询订单详情和商品信息(多对多)
     * @param orderNumber
     * @return
     */
    @Override
    public List<Orderdetail> getOrderAndDetail(String orderNumber) {
        List<Orderdetail> orderdetailList = orderMapper.findOrderAndDetailByOrderNumber(orderNumber);
        return orderdetailList;
    }
}
